<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>动态绑定 class 对象语法</title>
    <style>
        .textdecorated {
            text-decoration: underline;
        }

        .colordecorated {
            color: red;
        }
    </style>
</head>
<body>
<div id="app">
    <h1 class="colordecorated textdecorated">Hello, World!</h1>

    <!--  v-bind 动态绑定属性赋值不能是样式类  -->
    <h1 v-bind:class="{colordecorated: true, textdecorated:true}">Hello, World!</h1>
    <h1 v-bind:class="{colordecorated: false, textdecorated:true}">Hello, World!</h1>
    <h1 v-bind:class="{colordecorated: true, textdecorated:false}">Hello, World!</h1>
    <!--  使用变量控制样式类是否生效  -->
    <h1 v-bind:class="{colordecorated: isColorDecorated, textdecorated:isTextDecorated}">Hello, World!</h1>
    <h1 v-bind:class="abc">Hello, World!</h1>
</div>
<script type="module">

    import {createApp, ref, reactive} from "../../../../../js/vue.esm-browser.js";

    const app = createApp({
        setup() {

            let isTextDecorated = ref(true)
            let isColorDecorated = ref(true)

            let abc = reactive({
                colordecorated: true,
                textdecorated: true
            })


            return {
                isTextDecorated,
                isColorDecorated,
                abc,
            }
        }
    })

    app.mount("#app")
</script>
</body>
</html>